﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<% Newsletter obj = (Newsletter)ViewData.Model; %>
<script src="/Scripts/ckeditor/ckeditor.js" type="text/javascript"></script>
<script type="text/javascript">
    var formIndex = 0;
   
    $(document).ready(function () {
        CKEDITOR.replace('NewsContent', {
            filebrowserImageUploadUrl: '/Administration/Common/UploadImage',
            filebrowserFlashUploadUrl: '/Administration/Common/UploadFlash',
            entities: false
        });
        $("#cancel").click(function () {
                window.location = "/Administration/Newsletter/";
            });
        $("#newsletter_form").validate({
            debug: false,
            errorElement: "span",
            errorPlacement: function (error, element) {
                error.tooltip({
                    bodyHandler: function () {
                        return error.html();
                    }
                });
                error.insertAfter(element);
            },
            rules: {
                Title: { required: true }
                
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    success: function (result) {
                        if (result.MsgType == 1) {
                            JS_LIB.msgBox(result.MsgText, "400");
                        }
                        else {
                            //CKEDITOR.instances.TestContent.destroy();
                            window.location = "/Administration/Newsletter/Index";
                        }
                    },
                    url: form.action,
                    dataType: 'json',
                    cache: false,
                    iframe: true
                });

            }
        });
    });
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="edit">

   
    <tr>
        <td class="label required">
            Tiêu đề <span>*</span>
        </td>
        <td class="input">
            <% if (ViewData.Model == null)
               {
                   Response.Write(Html.TextBox("Title", "", new { @maxlength = "200", @style = "width:60%" }));
               }
               else
               {
                   Response.Write(Html.TextBox("Title", obj.Title, new { @maxlength = "200", @style = "width:60%" }));
               }
            %>
        </td>
    </tr>
    <tr>
        <td class="label required">
            Nội dung <span>*</span>
        </td>
        <td class="input">
            <% if (ViewData.Model == null)
               {
                   Response.Write(Html.TextArea("NewsContent", new { @style="width:60%"}));
               }
               else
               {
                   Response.Write(Html.TextArea("NewsContent", CommonFunc.SetHtmlForCKEditor(obj.NewsContent)));
               }
            %>
   
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center">
            <input type="submit" class="save" value="" id="save" alt="" />
            <input type="button" class="cancel" value="" alt="" id="cancel"/>
        </td>
    </tr>
</table>
